package it.ap.sa.acqua.tank.service.converter;

import org.springframework.stereotype.Component;

import it.ap.sa.acqua.dao.beans.TTankBean;
import it.ap.sa.acqua.dao.model.TTank;
import it.ap.sa.core.util.IBeanPopulate;

/**
 * Converter tra {@link TTank} e {@link TTankBean}
 * @author Alessandro Paolillo
 * @date 21 ott 2016
 * @version 1.0
 */
@Component
public class TankConverter implements IBeanPopulate<TTank, TTankBean>{

	public TankConverter() {
	}

	/**
	 * @author Alessandro Paolillo
	 * @date 21 ott 2016
	 * @version 1.0
	 * @see it.eng.tz.core.util.IBeanPopulate#convertdbToPage(java.lang.Object)
	 */
	@Override
	public TTankBean convertdbToPage(TTank src) throws Exception {
		TTankBean result = new TTankBean();
		if (src.getId()!=null) result.setId(src.getId());
		if (src.getIdUser()!=null) result.setIdUser(src.getIdUser());
		if (src.getNome()!=null) result.setNome(src.getNome());
		if (src.getAltezza()!=null) result.setAltezza(src.getAltezza());
		if (src.getCapacita()!=null) result.setCapacita(src.getCapacita());
		if (src.getLarghezza()!=null) result.setLarghezza(src.getLarghezza());
		if (src.getLunghezza()!=null) result.setLunghezza(src.getLunghezza());
		if (src.getPhMax()!=null) result.setPhMax(src.getPhMax());
		if (src.getPhMin()!=null) result.setPhMin(src.getPhMin());
		if (src.getGhMax()!=null) result.setGhMax(src.getGhMax());
		if (src.getGhMin()!=null) result.setGhMin(src.getGhMin());
		if (src.getKhMax()!=null) result.setKhMax(src.getKhMax());
		if (src.getKhMin()!=null) result.setKhMin(src.getKhMin());
		if (src.getTemperatureMax()!=null) result.setTemperatureMax(src.getTemperatureMax());
		if (src.getTemperatureMin()!=null) result.setTemperatureMin(src.getTemperatureMin());
		if (src.getNote()!=null) result.setNote(src.getNote());
		return result;
	}
	
	/**
	 * @author Alessandro Paolillo
	 * @date 21 ott 2016
	 * @version 1.0
	 * @see it.eng.tz.core.util.IBeanPopulate#convertpageToDb(java.lang.Object)
	 */
	@Override
	public TTank convertpageToDb(TTankBean src) throws Exception {
		TTank result = new TTank();
		if (src.getId()!=null) result.setId(src.getId());
		if (src.getIdUser()!=null) result.setIdUser(src.getIdUser());
		if (src.getNome()!=null) result.setNome(src.getNome());
		if (src.getAltezza()!=null) result.setAltezza(src.getAltezza());
		if (src.getCapacita()!=null) result.setCapacita(src.getCapacita());
		if (src.getLarghezza()!=null) result.setLarghezza(src.getLarghezza());
		if (src.getLunghezza()!=null) result.setLunghezza(src.getLunghezza());
		if (src.getPhMax()!=null) result.setPhMax(src.getPhMax());
		if (src.getPhMin()!=null) result.setPhMin(src.getPhMin());
		if (src.getGhMax()!=null) result.setGhMax(src.getGhMax());
		if (src.getGhMin()!=null) result.setGhMin(src.getGhMin());
		if (src.getKhMax()!=null) result.setKhMax(src.getKhMax());
		if (src.getKhMin()!=null) result.setKhMin(src.getKhMin());
		if (src.getTemperatureMax()!=null) result.setTemperatureMax(src.getTemperatureMax());
		if (src.getTemperatureMin()!=null) result.setTemperatureMin(src.getTemperatureMin());
		if (src.getNote()!=null) result.setNote(src.getNote());
		return result;
	}

}
